import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/common/department_user_tree_entity.dart';

DepartmentUserTreeEntity $DepartmentUserTreeEntityFromJson(Map<String, dynamic> json) {
  final DepartmentUserTreeEntity departmentUserTreeEntity = DepartmentUserTreeEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    departmentUserTreeEntity.id = id;
  }
  final String? companyCode = jsonConvert.convert<String>(json['companyCode']);
  if (companyCode != null) {
    departmentUserTreeEntity.companyCode = companyCode;
  }
  final String? departmentName = jsonConvert.convert<String>(json['departmentName']);
  if (departmentName != null) {
    departmentUserTreeEntity.departmentName = departmentName;
  }
  final dynamic departmentLevel = json['departmentLevel'];
  if (departmentLevel != null) {
    departmentUserTreeEntity.departmentLevel = departmentLevel;
  }
  final dynamic path = json['path'];
  if (path != null) {
    departmentUserTreeEntity.path = path;
  }
  final String? parentId = jsonConvert.convert<String>(json['parentId']);
  if (parentId != null) {
    departmentUserTreeEntity.parentId = parentId;
  }
  final String? deleted = jsonConvert.convert<String>(json['deleted']);
  if (deleted != null) {
    departmentUserTreeEntity.deleted = deleted;
  }
  final String? createDate = jsonConvert.convert<String>(json['createDate']);
  if (createDate != null) {
    departmentUserTreeEntity.createDate = createDate;
  }
  final String? createBy = jsonConvert.convert<String>(json['createBy']);
  if (createBy != null) {
    departmentUserTreeEntity.createBy = createBy;
  }
  final String? updateDate = jsonConvert.convert<String>(json['updateDate']);
  if (updateDate != null) {
    departmentUserTreeEntity.updateDate = updateDate;
  }
  final String? updateBy = jsonConvert.convert<String>(json['updateBy']);
  if (updateBy != null) {
    departmentUserTreeEntity.updateBy = updateBy;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    departmentUserTreeEntity.type = type;
  }
  final String? removeStatus = jsonConvert.convert<String>(json['removeStatus']);
  if (removeStatus != null) {
    departmentUserTreeEntity.removeStatus = removeStatus;
  }
  final List<DepartmentUserTreeEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<DepartmentUserTreeEntity>(e) as DepartmentUserTreeEntity).toList();
  if (children != null) {
    departmentUserTreeEntity.children = children;
  }
  final dynamic isPerson = json['isPerson'];
  if (isPerson != null) {
    departmentUserTreeEntity.isPerson = isPerson;
  }
  final int? taskCount = jsonConvert.convert<int>(json['taskCount']);
  if (taskCount != null) {
    departmentUserTreeEntity.taskCount = taskCount;
  }
  final dynamic tuserList = json['tuserList'];
  if (tuserList != null) {
    departmentUserTreeEntity.tuserList = tuserList;
  }
  final bool? isExpand = jsonConvert.convert<bool>(json['isExpand']);
  if (isExpand != null) {
    departmentUserTreeEntity.isExpand = isExpand;
  }
  return departmentUserTreeEntity;
}

Map<String, dynamic> $DepartmentUserTreeEntityToJson(DepartmentUserTreeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['companyCode'] = entity.companyCode;
  data['departmentName'] = entity.departmentName;
  data['departmentLevel'] = entity.departmentLevel;
  data['path'] = entity.path;
  data['parentId'] = entity.parentId;
  data['deleted'] = entity.deleted;
  data['createDate'] = entity.createDate;
  data['createBy'] = entity.createBy;
  data['updateDate'] = entity.updateDate;
  data['updateBy'] = entity.updateBy;
  data['type'] = entity.type;
  data['removeStatus'] = entity.removeStatus;
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  data['isPerson'] = entity.isPerson;
  data['taskCount'] = entity.taskCount;
  data['tuserList'] = entity.tuserList;
  data['isExpand'] = entity.isExpand;
  return data;
}

extension DepartmentUserTreeEntityExtension on DepartmentUserTreeEntity {
  DepartmentUserTreeEntity copyWith({
    String? id,
    String? companyCode,
    String? departmentName,
    dynamic departmentLevel,
    dynamic path,
    String? parentId,
    String? deleted,
    String? createDate,
    String? createBy,
    String? updateDate,
    String? updateBy,
    String? type,
    String? removeStatus,
    List<DepartmentUserTreeEntity>? children,
    dynamic isPerson,
    int? taskCount,
    dynamic tuserList,
    bool? isExpand,
  }) {
    return DepartmentUserTreeEntity()
      ..id = id ?? this.id
      ..companyCode = companyCode ?? this.companyCode
      ..departmentName = departmentName ?? this.departmentName
      ..departmentLevel = departmentLevel ?? this.departmentLevel
      ..path = path ?? this.path
      ..parentId = parentId ?? this.parentId
      ..deleted = deleted ?? this.deleted
      ..createDate = createDate ?? this.createDate
      ..createBy = createBy ?? this.createBy
      ..updateDate = updateDate ?? this.updateDate
      ..updateBy = updateBy ?? this.updateBy
      ..type = type ?? this.type
      ..removeStatus = removeStatus ?? this.removeStatus
      ..children = children ?? this.children
      ..isPerson = isPerson ?? this.isPerson
      ..taskCount = taskCount ?? this.taskCount
      ..tuserList = tuserList ?? this.tuserList
      ..isExpand = isExpand ?? this.isExpand;
  }
}
